import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5Vpk+TQB/OSnsuy5XBMg\n' +
  'H8LgfV+mHOyYZneGG/zPczw0ZT0bojaPIDRLgCBtrDMqWkgnWzmEyqqjASjuN0R2\n' +
  'LovaVAhSnZawERfIvq0UDQeyvtvJpm/GyOGJe7PjJdUGArp2+aGnS4QcGcsAIjch\n' +
  'MDhRtz5dA/sI+Lc5SrxvrJ/XBDwLWkUT0QBY1hEWaVo/gWFij9p91Xgf23xRKqGo\n' +
  'lxWksePC4q653izIXh1ipHeamurcQeakKUKi1kFXMRGdHG+2PIN5Nd86bkec8K/v\n' +
  'a6oC5WuPNB+SyltHrqzc6812JaB6PUkrY8konMHorNF48aLttGLxVQGUPRPmT2Dl\n' +
  'ywIDAQAB'

const privateKey = 'MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDlWmT5NAH85Key\n' +
  '7LlcEyAfwuB9X6Yc7Jhmd4Yb/M9zPDRlPRuiNo8gNEuAIG2sMypaSCdbOYTKqqMB\n' +
  'KO43RHYui9pUCFKdlrARF8i+rRQNB7K+28mmb8bI4Yl7s+Ml1QYCunb5oadLhBwZ\n' +
  'ywAiNyEwOFG3Pl0D+wj4tzlKvG+sn9cEPAtaRRPRAFjWERZpWj+BYWKP2n3VeB/b\n' +
  'fFEqoaiXFaSx48LirrneLMheHWKkd5qa6txB5qQpQqLWQVcxEZ0cb7Y8g3k13zpu\n' +
  'R5zwr+9rqgLla480H5LKW0eurNzrzXYloHo9SStjySicweis0Xjxou20YvFVAZQ9\n' +
  'E+ZPYOXLAgMBAAECggEAbK0ul17raje2tvOwyU5OtH4U/ZNrFN2PQU51f6GFcycd\n' +
  '9LLF+1E69JmTBP1YunXsJad27qUMpTPB1XTdm9aW4WtnYtYmv4F9oDvS5XcBv0Lc\n' +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'g62RFQ+OQaOJjo7KH5GPdyOSVdPcyHnTyp75hOCm5CQezCJwlWbH+Bk868fe5sum\n' +
  'B1Z/on116wQcPArB6S5gZi9LC/Z9cLLltcDMt/naxbVXi+sY0h3ZWXeHdeXMe86S\n' +
  'PkZRtpZraWIVnoi6Q5j9YOVb'

// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}

